<#import '/ftlLibrary/properteisVariable.ftl' as pv/>
<link href="assets/css/bootstrap-select.css" rel="stylesheet"/>
<link href="assets/css/front/listCommonStyle.css" rel="stylesheet"/>
<link href="assets/css/modify.css" rel="stylesheet"/>
<script src="assets/js/select2/select2.js"></script>
<div class="row margin-left-10">
	<!-- 映射列表 -->
	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
		<div class="widget flat margin-top-0" style="margin: -10px 0 0px 0!important;">
			<div class="widget-header bordered-sky theme-bordered nopadding">
				<div class="widget-buttons widget-label nomargin-bottom">
					<label class="businessBtns">
						<ol class="breadcrumb" style="margin: 0;">
							<li style="color: #809fa6;">系统管理</li>
							<li class="active" style="color: #23a8f5;">员工管理</li>
						</ol>
					</label>
				</div>
			</div>
		</div>
	</div>

	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
		<div class="widget flat searchCriteria " style="margin: 3px 0 0px 0!important;padding-bottom: 10px">
			<div class="widget-header bordered-sky theme-bordered nopadding">
				<div class="widget-buttons widget-label nomargin-bottom">
					<label class="businessBtns">
						<a type="btn" class="btn basicInfoBtn" href="javascript:toView('sysAdminUserController/sysAdminUserList.do',true,'POST',{pageSize:10})"
						   style="background-color: #23a8f5;border: none;border-radius: 4px!important;width: 140px;color: #fff;margin-right: 0!important;box-shadow:0px 0px 10px rgba(122,161,184,0.3);">
							员工管理
						</a>
					</label>
					<label class="pull-right businessBtns">
						<label class="margin-right-10">
							<@hp code="XTGLYGL90609973831405-list_add" params="[serializeNum=${serializeNum},targetDataId=]"/>
							<!--<a class="btn btn-warning shiny add" onclick="showDialogAddUser(this)" targetDataId="" serializeNum="${serializeNum}" style="border-radius: 0px;border: none;background: #ffab00  !important;">
								<i class="fa fa-plus"></i>新增管理员
							</a>-->
						</label>
						<label class="margin-right-10">
							<a style="border-radius: 0px;border: none;background: #23a8f5 !important;"
							   class="btn btn-blue shiny download"><i class="fa fa-share"></i>导出
							</a>
						</label>
						<label class="margin-right-10">
							<a style="border-radius: 0px;border: none;background: #ffab00 !important;"
							   class="btn btn-warning shiny search"><i class="fa fa-search"></i>搜索
							</a>
						</label>
					</label>
				</div>
			</div>
		</div>

		<div class="search_Bar" style="vertical-align: middle;clear: both;">
			<form id="${searchFormId}" action="${actionUrl}" class="searchConditions" method="POST">
				<div class="row searchInput" style="margin: 0;">
					<label class="iconchange1 hidden" style="position: absolute;right: 10px;top: 50px;" >
						<a class="search_Bar_A" style="color: #2a6496;cursor: pointer;" onclick="iconchangeShow(this)" value="1">筛选更多<i class="fa fa-chevron-down" style="padding-left: 5px"></i></a>
					</label>
					<label style="margin-bottom: 15px;margin-right: 40px;" class="search_Bar_item hidden">
						<label style="width: 78px">员工姓名：</label>
						<label>
							<input type="text" name="realName" value="${search_map.realName[0]}" style="width: 200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;">
						</label>
					</label>
					<label style="margin-bottom: 15px;margin-right: 40px;" class="search_Bar_item hidden">
						<label style="width: 78px">联系电话：</label>
						<label>
							<input type="text" name="phoneNumber" value="${search_map.phoneNumber[0]}" style="width: 200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;">
						</label>
					</label>
					<label style="margin-bottom: 15px;margin-right: 40px;" class="search_Bar_item hidden">
						<label style="width: 78px">员工职务：</label>
						<label>
							<select class="form-select-1" style="width: 200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;" name="post" >
								<option value="">请选择</option>
								<@dictionary groupCode="post";dics>
								<#list dics as dic>
									<option value="${dic.code}">${dic.value}</option>
								</#list>
							</@dictionary>
							</select>
						</label>
					</label>
					<label style="margin-bottom: 15px;margin-right: 40px;" class="search_Bar_item hidden">
						<label style="width: 78px">园所名称：</label>
						<label>
							<input type="text" name="sysSchool.schoolName" value="${search_map['sysSchool.schoolName'][0]}" style="width: 200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;">
						</label>
					</label>
				</div>
			</form>
		</div>

		<div class="widget flat radius-bordered" style="margin-top: 0;box-shadow:0px 0px 10px rgba(122,161,184,0.3);">
			<div class="widget-body no-padding">
				<div class="topPagingBar hidden">
					${pagingBar}
				</div>
				<div class="table-scrollable" style="border: none;" id="tableScrollable">
					<!-- 数据表列信息列表 -->
					<table class="table table-hover dataTable newtable">
						<thead>
							<tr>
								<th title="选择" class="checkboxColumnTh" fixed-align="left">
									<div class="checkbox">
	                                    <label>
	                                        <input type="checkbox" class="chkAll">
	                                        <span class="text"></span>
	                                    </label>
	                                </div>
								</th>
								<th title="属性名">序号</th>
								<th title="操作">操作</th>
								<th title="园所名称">园所名称</th>
								<th title="员工姓名">员工姓名</th>
								<th title="员工性别">员工性别</th>
								<th title="联系电话">联系电话</th>
								<th title="员工职务">员工职务</th>
								<th title="员工账号">员工账号</th>
								<th title="员工权限">员工权限</th>
								<th title="操作人">操作人</th>
								<th title="更新日期">更新日期</th>


								<!--<th title="主键">主键</th>-->
								<!--<th title="用户名">用户名</th>-->
								<!--<th title="密码">密码</th>-->
								<!--<th title="真实名称">真实名称</th>-->
								<!--<th title="邮箱">邮箱</th>-->
								<!--<th title="微信">微信</th>-->
								<!--<th title="QQ">QQ</th>-->
								<!--<th title="手机号">手机号</th>-->
								<!--<th title="座机号">座机号</th>-->
								<!--<th title="头像">头像</th>-->
								<!--<th title="是否可删除">是否可删除</th>-->
								<!--<th title="创建时间">创建时间</th>-->
								<!--<th title="最后修改时间">最后修改时间</th>-->
								<!--<th title="创建人">创建人</th>-->
								<!--<th title="是否禁用">是否禁用</th>-->
								<!--<th title="版本">版本</th>-->
								<!--<th class="fixedColumn" style="width: 100px">操作</th>-->
							</tr>
						</thead>
						<tbody>
							<#if page_bean.list?size==0>
								<tr>
									<td align="center">无数据</td>
								</tr>
							</#if>
							<#list page_bean.list as data>
								<tr>
									<td class="checkboxColumnTd">
										<div class="checkbox">
		                                    <label>
		                                        <input type="checkbox" class="chk"  name="id" value="${data.id}">
												<input type="checkbox" class="chk"  name="id" value="${data.id}">
		                                        <span class="text"></span>
		                                    </label>
		                                </div>
									</td>
									<td>${data_index+1+(page_bean.pageNo-1)*page_bean.pageSize}</td>
									<td align="center">
										<#if data.isForbidden==false>
										<@hp code="XTGLYGL90609973831405-list_table_tr_edit"
										params="[serializeNum=${serializeNum},editUrl=${editUrl},targetDataId=${data.id}]"
										/>

										<@hp code="XTGLYGL90609973831405-list_table_tr_delete"
										params="[serializeNum=${serializeNum},deleteUrl=${deleteUrl},targetDataId=${data.id}]"/>

										</#if>
										<#if data.isOpenAccount==true && data.isForbidden==false>
										<a onclick="showResetPasswordDialog(this)" serializeNum="${serializeNum}"
										   targetDataId="${data.id}">重置密码</a>
										</#if>
										<#if data.isForbidden==true>
											<a style="color: #2679B8" class="margin-right-10"
											   onclick="updateIsForbidden(this)" title="启用" targetDateId="${data.id}"
											   isForbidden="false">启用</a>
										</#if>
										<#if data.isOpenAccount==false>
											<a onclick="showOpenAccountDialog(this)" serializeNum="${serializeNum}"
											   targetDataId="${data.id}">开通账号</a>
										</#if>
										<#if  data.isForbidden==false>
											<a style="color: #2679B8" class="margin-right-10"
											   onclick="updateIsForbidden(this)" title="停用" targetDateId="${data.id}"
											   isForbidden="true">停用</a>
										</#if>
									</td>
									<td>${(data.sysSchool.schoolName???string(data.sysSchool.schoolName?html,""))!''}</td>
									<td>${(data.realName???string(data.realName?html,""))!''}</td>
									<td><@dictionary groupCode="sex" dictionaryCode="${data.sex}" ;sex>${sex.value }</@dictionary></td>
									<td>${(data.phoneNumber???string(data.phoneNumber?html,""))!''}</td>
									<td><@dictionary groupCode="post" dictionaryCode="${data.post}" ;post>${post.value }</@dictionary></td>
									<td>${(data.userName???string(data.userName?html,""))!''}</td>
									<td class="listId" value="${data.id}"></td>
									<td>${(data.sysAdminUser.realName???string(data.sysAdminUser.realName?html,""))!''}</td>
									<td>${(data.lastUpdateTime???string(data.lastUpdateTime?html,""))!''}</td>
									<td class="hidden">${(data.id???string(data.id?html,""))!''}</td>


									<!--<td>${(data.id???string(data.id?html,"未设置"))!'未设置'}</td>-->
									<!--<td>${(data.userName???string(data.userName?html,"未设置"))!'未设置'}</td>-->
									<!--<td>${(data.userPassword???string(data.userPassword?html,"未设置"))!'未设置'}</td>-->
									<!--<td>${(data.realName???string(data.realName?html,"未设置"))!'未设置'}</td>-->
									<!--<td>${(data.email???string(data.email?html,"未设置"))!'未设置'}</td>-->
									<!--<td>${(data.wechat???string(data.wechat?html,"未设置"))!'未设置'}</td>-->
									<!--<td>${(data.qq???string(data.qq?html,"未设置"))!'未设置'}</td>-->
									<!--<td>${(data.phoneNumber???string(data.phoneNumber?html,"未设置"))!'未设置'}</td>-->
									<!--<td>${(data.festnetznummer???string(data.festnetznummer?html,"未设置"))!'未设置'}</td>-->
									<!--<td>${(data.headPortrait???string(data.headPortrait?html,"未设置"))!'未设置'}</td>-->
									<!--<td>${data.isCanDelete?string('是','否')}</td>-->
									<!--<td>${(data.createTime???string(data.createTime?html,"未设置"))!'未设置'}</td>-->
									<!--<td>${(data.lastUpdateTime???string(data.lastUpdateTime?html,"未设置"))!'未设置'}</td>-->
									<!--<td>${(data.createUser???string(data.createUser?html,"未设置"))!'未设置'}</td>-->
									<!--<td>${data.isForbidden?string('是','否')}</td>-->
									<!--<td>${(data.version???string(data.version?html,"未设置"))!'未设置'}</td>-->
									<!--<td align="center">-->
										<!--<@hp code="XTGLYGL90609973831405-list_table_tr_edit" params="[serializeNum=${serializeNum},editUrl=${editUrl},targetDataId=${data.id}]" />-->

										<!--<@hp code="XTGLYGL90609973831405-list_table_tr_delete" params="[serializeNum=${serializeNum},deleteUrl=${deleteUrl},targetDataId=${data.id}]"/>-->

										<!--<#if  data.isForbidden==true>-->
									    	<!--<a onclick="showOpenAccountDialog(this)" serializeNum="${serializeNum}" targetDataId="${data.id}">开通账号</a>-->
									   <!--</#if>-->

										<!--<a onclick="showResetPasswordDialog()" serializeNum="${serializeNum}" targetDataId="${data.id}">重置密码</a>-->

										<!--<#if data.isForbidden==true>-->
										<!--<a style="color: #2679B8" class="margin-right-10" onclick="updateIsForbidden(this)" title="停用"  targetDateId="${data.id}" isForbidden="false">停用</a>-->
									<!--</#if>-->
									<!--<#if  data.isForbidden==false>-->
									<!--<a style="color: #2679B8" class="margin-right-10" onclick="updateIsForbidden(this)"  title="启用" targetDateId="${data.id}" isForbidden="true" >启用</a>-->
								<!--</#if>-->
									<!--</td>-->
								</tr>
							</#list>
						</tbody>
					</table>
				</div>
				 ${pagingBar}
			</div>
		</div>
	</div>
</div>
<script>
    $(".selectpicker").select2();

    //    隐藏显示搜索
    function iconsChange() {
        if ($(".iconsChangeA").val() == 1) {
            $(".iconsChangeA").val("0");
            $(".iconsChangeA").css("background", "url('assets/img/nav-img/icon_hidden.png')");
            $(".iconsChangeSpan").html("隐藏搜索栏");
            $(".search_Bar").removeClass("hidden");
        } else {
            $(".iconsChangeA").val("1");
            $(".iconsChangeA").css("background", "url('assets/img/nav-img/icon_show.png')");
            $(".iconsChangeSpan").html("显示搜索栏");
            $(".search_Bar").addClass("hidden");
        }
    }

    //    筛选下拉框
    setTimeout(function () {
        var size = $(".search_Bar_item").size();
        if (size > 8) {
            $(".iconchange1").removeClass("hidden");
            $(".search_Bar_item").each(function () {
                var index = $(this).index();
                if (index <= 8) {
                    $(this).removeClass("hidden")
                }
            })
        } else {
            $(".iconchange1").addClass("hidden");
            $(".search_Bar_item").each(function () {
                $(this).removeClass("hidden")
            })
        }
    }, 10)

    function iconchangeShow(that) {
        if ($(that).attr("value") == 1) {
            $(that).attr("value", "0");
            $(".iconchange1 .fa").removeClass("fa-chevron-down").addClass("fa-chevron-up");
            $(".search_Bar_item").each(function () {
                $(this).removeClass("hidden")
            })
        } else {
            $(that).attr("value", "1");
            $(".iconchange1 .fa").removeClass("fa-chevron-up").addClass("fa-chevron-down");
            $(".search_Bar_item").each(function () {
                var index = $(this).index();
                if (index <= 8) {
                    $(this).removeClass("hidden")
                } else {
                    $(this).addClass("hidden")
                }
            })
        }
    }

    /**
     * 新增
     * @param that
     */
	function showDialogAddUser(that) {
        var serializeNum = $(that).attr("serializeNum");
        var targetDateId= $(that).attr("targetdataid");
        ajaxRequest("sysAdminUserController/toEditView.do", {
            serializeNum: serializeNum,
            targetDateId: targetDateId
        }, function (html) {
            getTopWin().bootbox.dialog({
                message: html,
                className:"myDialog sysAdminUserEdit"
            });
            $(".modal-header").find(".bootbox-close-button").removeClass("close");
            $(".modal-header").find(".bootbox-close-button").html("");
        }, function () {
            ajaxError("加载页面失败!")
        }, "get", "html")
    }


    /**
     * 对员工停用启用操作
     * @param that
     */
    function updateIsForbidden(that) {
        var targetDateId = $(that).attr("targetDateId");
        var isForbidden = $(that).attr("isForbidden");
        ajaxRequest("sysAdminUserController/updateIsForbidden.do", {
            targetDateId: targetDateId,
            isForbidden: isForbidden
        }, function (result) {
            if (result.resCode == 200) {
                logger.info(result.resMsg, true);
                toView('sysAdminUserController/sysAdminUserList.do',true,'POST',{pageSize:10})
            } else {
                logger.error(result.resMsg);
            }
        }, function () {
            ajaxError("加载页面失败!")
        }, "post", "json")
    }

    /**
     * 开通权限
     * @param that
     */
    function showOpenAccountDialog(that) {
        var serializeNum = $(that).attr("serializeNum");
        var targetdataId = $(that).attr("targetdataid");
        ajaxRequest("sysAdminUserController/toOpenAccountView.do", {
            serializeNum: serializeNum,
            targetDataId: targetdataId
        }, function (html) {
            getTopWin().bootbox.dialog({
                message: html,
                title: "账号设置",
                className: 'myDialog openAccount'
            });
            $(".modal-header").find(".bootbox-close-button").removeClass("close");
            $(".modal-header").find(".bootbox-close-button").html("");
        }, function () {
            ajaxError("加载页面失败!")
        }, "get", "html")
    }

    function showResetPasswordDialog(that) {
        //switchView.do?viewPath=sysPage/platform/sysAdminUser/resetAdminUserPassword.html
        var serializeNum = $(that).attr("serializeNum");
        var targetdataId = $(that).attr("targetdataid");
        ajaxRequest("sysAdminUserController/toResetPassWordView.do", {
            serializeNum: serializeNum,
            targetDataId: targetdataId
		}, function (html) {
            getTopWin().bootbox.dialog({
                message: html,
                title: "重置密码",
                className: 'myDialog resetPassword'
            });
            $(".modal-header").find(".bootbox-close-button").removeClass("close");
            $(".modal-header").find(".bootbox-close-button").html("");
        }, function () {
            ajaxError("加载重置密码页面失败")
        }, "get", "HTML")
    }

    /**
     * 员工权限
     */
    $(function () {
        var listId = $(".listId");
        for (var i = 0; i < listId.length; i++) {
            var td=listId.eq(i);
			var listIdVal = td.attr("value");
            Http.postSync("sysAdminUserJoinSysRoleController/getLoginAdminRoles.do", {
                adminUserId: listIdVal
            }, function (result) {
                var data = result.data;
                var arr=new Array();
                $.each(data, function (i, t) {
                    arr.push(t.roleName);
                });
                td.html(arr.join("/"));
            }, function () {
                ajaxError("加载权限失败");
            }, "json");
		}
	})
</script>